//
//  QCWatchApi.swift
//  YFWatchDemo WatchKit Extension
//
//  Created by FYWCQ on 2019/6/28.
//  Copyright © 2019 YFWCQ. All rights reserved.
//

import Foundation
import Moya
import ObjectMapper

private extension String {
    var urlEscapedString: String {
        return self.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
    }
}


#if DEVELOPMENT
let urlHost = URL(string: "https://cloudtest.qingchengfit.cn")!
#else
let urlHost = URL(string: "https://cloud.qingchengfit.cn")!
#endif

//https://swift.gg/2016/04/22/using-xcode-targets/


public enum API {
    case userToken
    case passwordLogin
}

extension API: TargetType {
    public var baseURL: URL { return urlHost  }
    public var path: String {
        switch self {
        case .userToken:
            return "/api/csrftoken/"
        case .passwordLogin:
            return "/api/user/login/"
        }
    }
    public var method: Moya.Method {
        return .get
    }
    var parameters: [String: Any]? {
       return nil
    }
    public var task: Task {
        return Task.requestPlain
    }
    public var headers: [String : String]? {
        return nil
    }
    public var sampleData: Data {
        return "Half measures are as bad as nothing at all.".data(using: String.Encoding.utf8)!
    }

}
